Skip to content

Conversation

thyttan
Copy link
Collaborator

@thyttan thyttan commented Apr 20, 2025

... instead of the handling of them. This should add compatibility with
most apps, even if Bangle.setUI is not used.

Ping @nxdefiant and @jt-nti , what do you think of this approach?

I'm also thinking of adding settings so horizontal and vertical inversion can be set individually, also per app.

thyttan added 2 commits April 20, 2025 20:20
…modify the

	events instead of the handling of them. This should add compatibility with
	most apps, even if Bangle.setUI is not used.
@thyttan thyttan changed the title swipeinv: (WIP) Add inversion of drag events. Refactor to hijack and modify the swipeinv: (WIP) Add inversion of drag events. Refactor to hijack and modify the events Apr 20, 2025
@nxdefiant
Copy link
Contributor

nxdefiant commented Apr 21, 2025

Nice, I have not tested this, but looks good to me.

@thyttan
Copy link
Collaborator Author

thyttan commented May 1, 2025

I think this works now, can be tried at https://thyttan.github.io/BangleApps/?id=swipeinv

not looking to merge yet though.

@jt-nti
Copy link
Contributor

jt-nti commented May 2, 2025

@thyttan looks interesting, I'll give it a try when I get a chance, thanks

@thyttan
Copy link
Collaborator Author

thyttan commented May 2, 2025

I think I notice this approach making the watch feel a bit slower than the old one. So that's a minus in that case. But not conclusive, just a feeling.

@thyttan
Copy link
Collaborator Author

thyttan commented May 2, 2025

I also had the idea to do the inversions by wrapping the listener functions at their registration. That way swipeinv would not depend on being first in the listener call chain to work.

It's here: thyttan@5cbb72e

But I didn't get that to work yet.

@thyttan
Copy link
Collaborator Author

thyttan commented May 4, 2025

Doesn't feel too much slower (if at all) now since I added ram keyword to functions.

@thyttan thyttan marked this pull request as ready for review August 17, 2025 11:45
@thyttan thyttan changed the title swipeinv: (WIP) Add inversion of drag events. Refactor to hijack and modify the events swipeinv: Add inversion of drag events. Refactor to hijack and modify the events Aug 17, 2025
@gfwilliams
Copy link
Member

So you're happy to merge this now?

As it's just an optional app I feel like there's no problem merging this in?

@thyttan
Copy link
Collaborator Author

thyttan commented Sep 2, 2025

Yes I believe it can go in 🙂

If I find a better approach I can do another PR. But on that note, do you think wrapping listener functions (Bangle.on/prependListener) could be better? I suspect it may not be possible without significantly slowing things down though.

I also had the idea to do the inversions by wrapping the listener functions at their registration. That way swipeinv would not depend on being first in the listener call chain to work.

It's here: thyttan@5cbb72e

But I didn't get that to work yet.

@gfwilliams
Copy link
Member

Thanks! I reckon the current method is good enough. Overriding .on/etc feels like it's going to cause issues (removeListener likely won't work then).

Although looking at it, because drag passes an object, you don't need all the re-emit stuff that dragInverter does. Just:

let dragInverter = (e) => {
        "ram"
        const APP_ID = getAppIdFromCurrentFile();
        if (SETTINGS.global ^ Object.keys(SETTINGS.apps).includes(APP_ID)) {
            e.inverted = true;
            if (SETTINGS.global ^ (SETTINGS.apps[APP_ID]&&SETTINGS.apps[APP_ID].dragH)) {e.dx *= -1;}
            if (SETTINGS.global ^ (SETTINGS.apps[APP_ID]&&SETTINGS.apps[APP_ID].dragV)) {e.dy *= -1;}
        }
      }

Because subsequent functions in that chain will get the same (modified) object. That'll speed it up.

swipeInverter needs to be as-is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants